<template>
    <div>
<h2>登录</h2>
<table class="table table-bordered">
    <tr>
        <td algin="right">用户名</td>
        <td><input type="text"  v-model="state.name" /></td>
    </tr>
    <tr>
        <td algin="right">密码</td>
        <td><input type="password" v-model="state.pwd" /></td>
    </tr>
    <tr>
        <td algin="right"></td>
        <td><input type="button" value="登录" @click="login" /></td>
    </tr>
</table>
    </div>
</template>

<script setup lang="ts">
import { reactive,toRefs } from 'vue';
import axios from 'axios';
import { useRouter,useRoute } from 'vue-router';
let router=useRouter()
let data=reactive({
    state:{
        name:'',
        pwd:''
    }
})
let {state}=toRefs(data)
const login=()=>{
    let obj={
        name:state.value.name,
        pwd:state.value.pwd
    }
    axios({
        url:'/api/HouseMoeny/Login',
        method:'post',
        params:obj
    })
    .then(res=>{
        console.log(res)
        if(res.data.data==1){
            alert("登录成功")
            router.push("/add")
        }
        else{
            alert("登录失败")
        }
    })
    .catch(err=>{
        console.log(err)
    })
}
</script>

<style scoped>

</style>